<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page import="wpmp.portal.Configurations"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<title>wpmp-登录</title>
<%@ include file="/commons/meta.jsp" %>
<%@ include file="/commons/header.jsp" %>
<%@ include file="/ext3/import.jsp" %>
<%@ include file="/easyext3/import.jsp" %>
<style type="text/css">
.main-footer {
	text-align: center;
	font-family: "微软雅黑";
	font-size: 12px;
	color: #026e62;
}
</style>
<script language="javascript" type="text/javascript">
function login(formPanel) {
	var accessUrl = '${ctx}/login.do';
	if (!formPanel.form.isValid()) {
		return;
	}
	formPanel.form.submit({
		method: 'post',
		waitTitle: ' ',
		waitMsg: '正在登录, 请稍后... ...',
		url: accessUrl,
		failure: function(form,action) {
	 		if(action.result.msg) {
        		Ext.Msg.alert('',action.result.msg);
        	}
		},
		success: function(form,action) {
			var result=action.result;
			EasyExt.parse(result, function(buttonId) {
				Ext.Msg.hide();
				if(result.pass||buttonId=='yes') {
					window.location.href='${ctx}/main.do';
				}
			});
		}
	});
}

var loginFormPanel=new Ext.form.FormPanel({
	bodyStyle: 'padding-top:10px',
	defaultType: 'textfield',
	labelAlign: 'right',
	labelWidth: 75,
	height: 115,
	frame: true,
	defaults: {
		validateOnBlur: false,
		allowBlank: false,
		width: 250
	},
	items: [{
		name: 'loginName',
		fieldLabel: '用户名',
		enableKeyEvents: true,
		listeners: {
			keydown: function(thiz, e) {
				if (e.getKey()==13) {
					login(loginFormPanel);
				}
			},
			afterrender: function(thiz) {
				this.setRawValue('${loginName}');
				this.focus(true, 500);
			}
		}
	},{
		name: 'password',
		fieldLabel: '密码',
		inputType: 'password',
		enableKeyEvents: true,
		listeners: {
			keydown: function(thiz, e) {
				if(e.getKey()==13){
					login(loginFormPanel);
				}
			},
			afterrender: function(thiz) {
				this.setRawValue('${password}');
			}
		}
	},{
		allowBlank: true,
		xtype: 'checkbox',
		fieldLabel: '十天免登录',
		name: 'rememberPassword',
		inputValue: true
	}]
});

var loginWindow = new Ext.Window({
	title: '用户登录/可使用VPN账号',
	width: 360,
	height: 180,
	closable: false,
	draggable: false,
	collapsible: false,
	resizable: false,
	defaults: {              
		border: false
	},
	items: loginFormPanel,
	buttonAlign: 'center',
	buttons: [{
		text: '登陆',
		handler: function() {
			login(loginFormPanel);
		}
	},{
		text: '重置',
		handler: function() {
			loginFormPanel.form.reset();
			loginFormPanel.get(0).focus(true,500);
		}
	}]
});

Ext.onReady(function() {
	var viewport=new Ext.Viewport({
		layout: 'border',
		items: [{
			region: 'north',
			height: 25,
			layout: 'fit',
			xtype: 'box',
			html: ''
		},
		{
			region: 'south',
			height: 16,
			layout: 'fit',
			xtype: 'box',
			border: true,
			html: '<div class="main-footer"><%=Configurations.getMainFooterText()%>&nbsp;©&nbsp;2013</div>'
		},
		{
			region: 'center',
			layout: 'fit',
			xtype: 'panel',
			border: true
		}]
	});
	loginWindow.show();
});
</script>
</head>
<body>
</body>
</html>